package 力扣日常刷题.木23四月.第4天404;

import java.util.HashMap;

public class CarFactory {


    private volatile static  HashMap<String,Car> cars;



    public Car buildCar(String type) {
        Car car = cars.getOrDefault(type, null);
        if(car != null) {
            car.build();
            return  car;
        }
        if(type == "wl") {
            if(car == null) {
                synchronized (WLCar.class) {
                    car = new WLCar();
                    cars.put(type,car);
                }
            }
        }
        car.build();
        return  car;
    }


}
